﻿#region Copyright (c) Nicola Gallo All rights reserved.
/*
 * All rights reserved. Reproduction of trasmission of this file, or a portion thereof,
 * is forbidden without prior written permission of Nicola Gallo.
 * 
 * Author: Nicola Gallo
 * Date: 09/04/2011
 * 
 * */
#endregion
namespace PrismMVC.ModuleA.ViewModels
{
    //.NET References
    using System;
    using System.ComponentModel;
    using System.Linq;
    using System.Windows.Data;

    //Microsoft References
    using Microsoft.Practices.Prism.Commands;
    using Microsoft.Practices.Prism.Events;
    using Microsoft.Practices.Prism.Logging;
    using Microsoft.Practices.Prism.Regions;
    using Microsoft.Practices.Prism.ViewModel;
    using Microsoft.Practices.Unity;

    //PrismMVC References
    using PrismMVC.ModuleA.Data;
    using PrismMVC.ModuleA.Services;
    using PrismMVC.Shell.Containers;

    /// <summary>
    /// PresentationModel for ShowPerson.
    /// </summary>
    public class ShowPersonPM : PresentationModel
    {
        //Fields

        private Person _currentPerson;

        //Constructors

        /// <summary>
        /// Creates a new instance of <see cref="ShowPersonPM"/>.
        /// </summary>
        /// <param name="unityContainer">Unity container.</param>
        /// <param name="loggerFacade">Logger facade.</param>
        /// <param name="eventAggregator">Event aggregator.</param>
        /// <param name="personsService">Persons service.</param>
        public ShowPersonPM(IUnityContainer unityContainer, ILoggerFacade loggerFacade, IEventAggregator eventAggregator, IPersonsService personService)
            : base(unityContainer, loggerFacade, eventAggregator)
        {
            
        }

        //Properties

        /// <summary>
        /// Gets/Sets current person.
        /// </summary>
        public Person CurrentPerson 
        {
            get 
            {
                return this._currentPerson;
            }
            set 
            {
                if (this._currentPerson != value)
                {
                    this._currentPerson = value;
                    this.OnPropertyChanged("CurrentPerson");
                }
            }
        }

        //Methods

        /// <summary>
        /// Initialzation code.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            this.CurrentPerson = this.ViewData["currentPerson"] as Person;
        }
    }
}